import { getLocal, setLocal } from '@/utils/localStorage'
import { defineStore } from 'pinia'

const useLayoutStore = defineStore('layout', {
    //该文件中的数据为极其重要数据，不可随意修改

    state: () => ({
        maxIndent: 225, //侧边栏展开宽度
        minIndent: 80, //侧边栏折叠宽度
        nowIndent: 225, //侧边栏初始的宽度
        navIndent: 100, // 导航栏的高度
        inlineIndent: 18, //侧边栏内边距
        navRouterList: [] as any[], //导航栏的路由列表
        nowSliderKeys: [] as any[], //当前侧边栏的选中项
        spinning: false, //加载状态
        theme: getLocal('theme') || 'dark' //主题
    }),
    actions: {
        setTheme(value: string) {
            this.theme = value
            setLocal('theme', value) //持久化
        }
    }
})

export default useLayoutStore
